<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
        $this->display();
    }
    public function welcome(){
        $this->display();
    }
    // 修改密码
    public function edit(){
        $admin=D('admin');
        if(IS_POST){
            if($admin->create()){
                $admin->password=md5($admin->password);
                if($admin->save()){
                    $this->assign('jumpUrl','javascript:parent.layer.closeAll();');

                    $this->success('修改管理员成功！');
                }else{
                    $this->error('修改管理员失败');
                }
            }else{
                $this->error($admin->getError());
            }

            return;
        }
        $id=I('id');
        $adminres=$admin->find($id);
        $this->assign('adminres',$adminres);
        $role=D('role');
        $roles=$role->select();
        $this->assign('roles',$roles);
        $this->display();
    }
}